package com.slz3.business.module.instantMessaging.insMessaging.service;

import com.slz3.business.frame.module.Repositorys;
import com.slz3.business.module.instantMessaging.insMessaging.domain.InsMessaging;
import com.slz3.business.module.instantMessaging.insMessaging.domain.InsMessagingFactory;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import java.time.LocalDateTime;
import java.util.List;

@Slf4j
@Service
public class InsMessagingTransactionalServiceImpl implements InsMessagingTransactionalService {

    @Override
    public InsMessaging modify(InsMessaging insMessagingNew) {
        Repositorys.insMessaging.test();
        Repositorys.insMessaging.save(InsMessagingFactory.initBaseFields());
        System.err.println(1 / 0);
        insMessagingNew.setLastModifyTime(LocalDateTime.now());
        return Repositorys.insMessaging.saveAndFlush(insMessagingNew);
    }

    @Override
    public List<InsMessaging> batchModify(List<InsMessaging> insMessagingList) {
        return Repositorys.insMessaging.saveAll(insMessagingList);
    }
}
